'use client';

import { verifyJwtToken } from '@/lib/jwt';
import Cookies from 'js-cookie';
import { useEffect, useState } from 'react';

export const useAuth = () => {
    const [auth, setAuth] = useState(null);
    const getVerifiedToken = async () => {
        const token = Cookies.get('token') ?? null;
        const verifiedToken = await verifyJwtToken(token);
        setAuth(verifiedToken);
    };
    useEffect(() => {
        getVerifiedToken();
    }, []);
    return auth;
};
